//
//  XTCSearchConditionShow.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/4/8.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XTCSearchConditionShow.h"

#import "XXTool.h"

@implementation XMLSearchConditionShowModel

+(NSMutableArray<XMLSearchConditionShowModel*> *)localSearchConditionData
{
    NSMutableArray *dataArray = [[NSMutableArray alloc] init];
    for (int i=0;i<3; i++)
    {
        XMLSearchConditionShowModel *temp = [[XMLSearchConditionShowModel alloc] init];
        if (i==0)
        {
            temp.leftString = NSLocalizedString(@"名称", nil);
            temp.isHiddenArrow = NO;
        }
        else if (i==1)
        {
            temp.leftString = NSLocalizedString(@"国家", nil);
            temp.isHiddenArrow = YES;
        }
        else if (i==2)
        {
            temp.leftString = NSLocalizedString(@"类别", nil);
            temp.isHiddenArrow = YES;
        }
        [dataArray addObject:temp];
    }
    return dataArray;
}

@end


@interface XTCSearchConditionShow ()

@property (nonatomic,strong) UILabel *dropUseLeft;
@property (nonatomic,strong) UIImageView *dropUseRight;

@end

@implementation XTCSearchConditionShow
{
    XMLSearchConditionShowModel *nowModel;
}

-(UILabel*)dropUseLeft
{
    if (_dropUseLeft==nil)
    {
        _dropUseLeft = [[UILabel alloc] init];
        _dropUseLeft.textColor = [UIColor whiteColor];
        if([XXTool didCurrentLanguageChinese])
        {
            _dropUseLeft.font = [XXTool systemFontOfSize:15];

        }
        else
        {
            _dropUseLeft.frame = CGRectMake(10, 0, 70, 35);
            _dropUseLeft.font = [XXTool systemFontOfSize:13];
        }
        [self addSubview:_dropUseLeft];
    }
    return _dropUseLeft;
}

-(UIImageView*)dropUseRight
{
    if (_dropUseRight==nil)
    {
        _dropUseRight = [[UIImageView alloc] init];
        _dropUseRight.image = [UIImage imageNamed:@"向下箭头"];
        _dropUseRight.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:_dropUseRight];
    }
    return _dropUseRight;
}

-(void)initUI
{
    self.backgroundColor = [UIColor colorWithRed:172/255.0 green:172/255.0 blue:172/255.0 alpha:1.0];
    [self dropUseLeft];
    [self dropUseRight];
}

-(void)refreshLayout:(CGRect)frame
{
    _dropUseRight.frame = CGRectMake(48
                                     , (frame.size.height-8)/2+2
                                     , 15
                                     , 8);
    _dropUseRight.hidden = nowModel.isHiddenArrow;
    
    if([XXTool didCurrentLanguageChinese])
    {
        _dropUseLeft.frame = CGRectMake(10
                                        , 0
                                        , 35
                                        , 35);
    }
    else
    {
        _dropUseLeft.frame = CGRectMake(10, 0, 70, 35);
        _dropUseRight.hidden = YES;
    }
}

-(void)setCellWithData:(XMLSearchConditionShowModel *)model
{
    nowModel = model;
    _dropUseLeft.text = model.leftString;
    [self refreshLayout:self.frame];
}

@end
